import { Result } from "route-recognizer";

export function normalizeRoutes(items: RouteConfig[]): NormalizeRouteItem[] {
    let routes: NormalizeRouteItem[] = [];
    for (let item = items.length - 1; item >= 0; item--) {
        routes.push({ path: items[item].path, handler: items[item] })
    }
    return routes;
}
export function normalizeRoute(originData: Result) {
    let route:RevealableRoute;
    let res = originData;
    let handler = res.handler as RouteConfig;
    route = {
        param: res.params,
        ...handler
    }
    return route;
}
export function normalizePath(path:string){
    if(path.charAt(0)!=="/"){
        path.padStart(1,"/");
    }
    return path;
}